#!/bin/bash
sed -i "s/CONTAINERS_IDS/${CONTAINERS_IDS}/g" /usr/share/filebeat/filebeat.yml
sed -i "s/CONTAINERS_PATH/${CONTAINERS_PATH}/g" /usr/share/filebeat/filebeat.yml
sed -i "s/OUTPUT_CONSOLE_ENABLE/${OUTPUT_CONSOLE_ENABLE}/g" /usr/share/filebeat/filebeat.yml
sed -i "s/OUTPUT_KAFKA_ENABLE/${OUTPUT_KAFKA_ENABLE}/g" /usr/share/filebeat/filebeat.yml
sed -i "s/KAFKA_HOSTS/${KAFKA_HOSTS}/g" /usr/share/filebeat/filebeat.yml
sed -i "s/KAFKA_VESION/${KAFKA_VESION}/g" /usr/share/filebeat/filebeat.yml
sed -i "s/KAFKA_INVALID_TOPIC/${KAFKA_INVALID_TOPIC}/g" /usr/share/filebeat/filebeat.yml
sed -i "s/KAFKA_TOPIC/${KAFKA_TOPIC}/g" /usr/share/filebeat/filebeat.yml
sed -i "s/KAFKA_REQUIRED_ACKS/${KAFKA_REQUIRED_ACKS}/g" /usr/share/filebeat/filebeat.yml
sed -i "s/KAFKA_COMPRESSION/${KAFKA_COMPRESSION}/g" /usr/share/filebeat/filebeat.yml
sed -i "s/KAFKA_MAX_MESSAGE_BYTES/${KAFKA_MAX_MESSAGE_BYTES}/g" /usr/share/filebeat/filebeat.yml
sed -i "s/PROCESSORS_JSON_FILEDS/${PROCESSORS_JSON_FILEDS}/g" /usr/share/filebeat/filebeat.yml
sed -i "s/PROCESSORS_JSON_PROCESS_ARRAY/${PROCESSORS_JSON_PROCESS_ARRAY}/g" /usr/share/filebeat/filebeat.yml
sed -i "s/PROCESSORS_JSON_MAX_DEPTH/${PROCESSORS_JSON_MAX_DEPTH}/g" /usr/share/filebeat/filebeat.yml
sed -i "s/PROCESSORS_JSON_TARGET/${PROCESSORS_JSON_TARGET}/g" /usr/share/filebeat/filebeat.yml
sed -i "s/PROCESSORS_JSON_OVERWRITE_KEYS/${PROCESSORS_JSON_OVERWRITE_KEYS}/g" /usr/share/filebeat/filebeat.yml

cat /usr/share/filebeat/filebeat.yml

cd /usr/share/filebeat 
nohup filebeat -c filebeat.yml > ./filebeat.out &
tail -f filebeat.out